package com.controller;

import com.entity.User;
import com.service.UserService;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by ${Ljx} on 2017/7/21.
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;


    @RequestMapping(value = "/getallusers",method = {RequestMethod.POST,RequestMethod.GET})
//    public ModelMap getallusers(User user,ModelMap m){
    public @ResponseBody List<User> getallusers(User user,ModelMap m){
        List<User> list = userService.getallusers();
        User user1 = new User();
        user1.setId("111");
        user1.setName("出错了");
        user1.setPassword("123");
        System.out.println("================================>>>"+list.toString());
        if(list.size()<=0){
            list.add(user1);
        }
        return list;
    }
}
